package muse;

import java.lang.reflect.InvocationTargetException;
import java.util.Timer;
import java.util.TimerTask;

import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import muse.Frame.MFrame;

/*
 * A simple main class to initialize the main Window and start the initial run sequences.
 */

public class Launcher extends JApplet {
    
    public static String greetings[] = {
            "I believe I can impress you in a hundred different ways! Are you impressed yet?",
            "Tomorrow is always another day, but today is the best time to start something!",
            "I hope you've come to impress me.  I've had a bad day.",
            "It's not a good idea to work for too long at once!  Come take a break and see me once in a while :3",
            "If 16*4=64, then 17*5 = 75?  Hmm... I never was good at Math.",
            "Oh man, I bet your name is Amanda, isn't it!  My oh my, you are so hot.  *o*"
        };
    
	/* Exactly what it says.  The version number. */
	public static int VERSION = 2; 
	
	/* The main display frame. */
	private static Window window; 
	
	/*
	 * Returns the main Window being used by this instance of the program.
	 * 
	 * @return		the program's Window
	 */
	public static Window getWindow() {
		return window;
	}
	
	public void init() {
		try {
			SwingUtilities.invokeAndWait(new Runnable() {
				public void run() {
					window = new Window(320,480);
					add(window);
				}
			});
		} catch (InterruptedException e) {
			JOptionPane.showMessageDialog(null, e.getCause().toString());
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			JOptionPane.showMessageDialog(null, e.getCause().toString());
			e.printStackTrace();
		}

	}
	public void stop() {
		
	}
	public void start() {
		setVisible(true);	
		
		/*
		 * Set the current Frame to the splash screen, then after 5 seconds, change to the Main screen
		 */
		window.changeScreen(MFrame.SPLASH);
		new Timer().schedule(new TimerTask() {
			public void run() {
				window.changeScreen(MFrame.PORTAL);
			}
		}, 1000);
	}
	public static void main(String[] args) {
		Launcher launch;
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.add(launch = new Launcher());
		launch.init();
		launch.start();
		frame.setVisible(true);
		frame.pack();
	}
}
